<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script>
    function c() {
      let userName = document.getElementById("tid").value;
      let zz = /[A-Z][a-z]{2}/;
      let flag = true;
      if(!zz.test(userName)) {
        let elementById = document.getElementById("sid1");
        elementById.innerText="格式错误";
        flag = false;
      }
      let passWord = document.getElementById("pid").value;
      let z = /[a-z][0-9]{2}/;
      if(!z.test(passWord)) {
        let elementById1 = document.getElementById("sid2");
        elementById1.innerText="格式错误";
        flag = false;
      }
      return flag;
    }
  </script>
</head>
<body>
    <form action="https://www.baidu.com" onsubmit="return c()">
      用户名:<input type="text" name="user" placeholder="填写用户名" id="tid">
      <span id="sid1"></span><br>
      密码:   <input type="password" name="password" placeholder="请填写用户密码" id="pid">
      <span id="sid2"></span><br>
      <input type="submit" value="表单提交">
    </form>
</body>
</html>